package pkg

import (
	"commerce/config"
	"encoding/json"
	"fmt"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
)

type CensorClet struct {
	conclusionType uint64 `json:"conclusionType"`
}

func Censor(str string) bool {
	client := censor.NewClient(config.Conf.Censor.Ak, config.Conf.Censor.Sk)
	//如果是百度云ak sk,使用下面的客户端

	res := client.TextCensor(str)

	fmt.Println(res)

	var result CensorClet

	err := json.Unmarshal([]byte(res), &result)
	if err != nil {
		return false
	}
	if result.conclusionType == 1 {
		return true
	}

	return false
}
